package nl.myhealth.app.myhealthapp.Measurement;

import android.util.Log;

import org.json.JSONObject;

import java.util.Date;

/**
 * Created by Stephan E G Veenstra on 28-9-2014.
 */
public class PressureMeasurment extends Measurement {

    private int systolic;
    private int diastolic;

    public PressureMeasurment(Date timestamp,int systolic,int diastolic)
    {
        super(timestamp);
        setSystolic(systolic);
        setDiastolic(diastolic);
    }

    public PressureMeasurment(String json)
    {
        try {
            JSONObject m = new JSONObject(json);
            Log.w("PULSEMEASUREMENT parsed", m.getString("timestamp"));
            setSystolic(m.getInt("systolic"));
            setDiastolic(m.getInt("diastolic"));
            setTimestamp(m.getString("timestamp"));

        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public int getSystolic() {
        return systolic;
    }

    public void setSystolic(int systolic) {
        this.systolic = systolic;
    }

    public int getDiastolic() {
        return diastolic;
    }

    public void setDiastolic(int diastolic) {
        this.diastolic = diastolic;
    }

    @Override
    public String toJsonString() {
        return "{\"timestamp\":\"" + getTimestampString() + "\",\"systolic\":" + getSystolic() + "," +
                "\"diastolic\":" + getDiastolic() + "}";
    }
}
